﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace MyLibellus
{
    class DBAccess
    {
        public static SqlConnection getConnection()
        {
            string s = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
            SqlConnection sqlcon = new SqlConnection(s);
            return sqlcon;
        }

        public static DataTable getDataTAble(string nomTaula)
        {
            return new DataTable(nomTaula);
        }

        public static SqlDataAdapter getAdapter(string select, SqlConnection con, DataTable dt)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(select, con);
            adapter.Fill(dt);
            return adapter;
        }

        

        public static DataTable getTable(string select)
        {
            SqlCommand cmd = new SqlCommand(select, getConnection());
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;

            DataTable dtGet = new DataTable();
            da.Fill(dtGet);
            return dtGet;
        }

        

    }
}
